package com.wangyk.rabbitmqcommon.utils;

import com.wangyk.rabbitmqcommon.VO.ResultVO;
import com.wangyk.rabbitmqcommon.enums.ResultEnum;

/**
 * 返回给前端的数据
 */
public class ResultVOUtils
{
    /**
     * 成功时返回的数据
     */
    public static ResultVO success()
    {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
        return resultVO;
    }

    /**
     * 成功时返回的数据
     */
    public static ResultVO success(ResultVO resultVO)
    {
        resultVO.setCode(ResultEnum.SUCCESS.getCode());
        resultVO.setMessage(ResultEnum.SUCCESS.getMessage());
        return resultVO;
    }

    /**
     * 失败时返回的数据
     */
    public static ResultVO error(ResultEnum resultEnum)
    {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(resultEnum.getCode());
        resultVO.setMessage(resultEnum.getMessage());
        return resultVO;
    }

    /**
     * 失败时返回的数据
     */
    public static ResultVO error()
    {
        ResultVO resultVO = new ResultVO();
        resultVO.setCode(ResultEnum.ERROR.getCode());
        resultVO.setMessage(ResultEnum.ERROR.getMessage());
        return resultVO;
    }
}
